<template>
  <h1>{{ title }}</h1>
  <el-form :model="form" label-width="120px">
    <el-form-item label="用户名">
      <el-input v-model="form.username" />
    </el-form-item>
    <el-form-item label="密码">
      <el-input v-model="form.passwrod" />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">Create</el-button>
    </el-form-item>
  </el-form>

  <img src="/vite.svg" />
  <img src="../assets/vue.svg" />
</template>

<script>
export default {
  name: "login",
  props: ["title"],
  data() {
    return {
      form: {
        username: "",
        passwrod: "",
      },
    };
  },
  methods: {
    handle() {
      // 子组件向父组件传值
      this.$emit("changeUsername", this.form.username);
    },
    onSubmit() {
      console.log(this.form);
      this.$axios
        .post("/test/login", this.form)
        .then((result) => {
          console.log(result);
        })
        .catch((err) => {
          console.error(err);
        });
    },
  },
};
</script>
